package com.mc.code.service.Impl;

import com.mc.code.entity.Advise;
import com.mc.code.mapper.AdviseMapper;
import com.mc.code.service.AdviseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdviseServiceImpl implements AdviseService {
    @Autowired
    private AdviseMapper adviseMapper;
    @Override
    public int insertMessage(Advise advise) {
        return adviseMapper.insertMessage(advise);
    }

    @Override
    public int findMaxMessageNo() {
        String messageNo1 = adviseMapper.findMaxMessageNo();
        int messageNo=0;
        if (messageNo1!=null) {
             messageNo = Integer.parseInt(messageNo1);
        }
        if(messageNo != 0 ){
            return messageNo + 1;
        }else {
            return 100000;
        }

    }


    @Override
    public List<Advise> findUnansweredMessage() {
        return adviseMapper.findUnansweredMessage();
    }

    @Override
    public List<Advise> findAnsweredMessage() {
        return adviseMapper.findAnsweredMessage();
    }
}
